function drawChart1(c1){
	var option = {
	    tooltip : {
	        trigger: 'item',
	        formatter: "{a} <br/>{b} : {c} ({d}%)",
	        position:function(p){   //其中p为当前鼠标的位置
	            return [p[0] + 10, p[1] - 10];
	        },
	        labelLine :{show:true}
	    },
	    legend: {
	        orient: 'vertical',
	        left: 'left',
	        data: ['门诊收入','住院收入']
	    },
	    series : [
	        {
	            name: '收入来源',
	            type: 'pie',
	            radius : '55%',
	            center: ['50%', '60%'],
	            data:[
	                {value:264286, name:'门诊收入'},
	                {value:3659344, name:'住院收入'}
	            ],
	            itemStyle: {
	                emphasis: {
	                    shadowBlur: 10,
	                    shadowOffsetX: 0,
	                    shadowColor: 'rgba(0, 0, 0, 0.5)'
	                },
	                normal:{
	                	color: function(params) {
                            // build a color map as your need.
                            var colorList = ['#27727B','#E87C25'];
                            return colorList[params.dataIndex];
                        }
	                }
	            }
	        }
	    ]
	};
	c1.setOption(option);
}

function drawChart2(c2){
	var option = {
			tooltip: {
	        trigger: 'axis',
	        axisPointer: {
	            type: 'cross',
	            crossStyle: {
	                color: '#999'
	            }
	        }
	    },
	    legend: {
	        data:['门诊人数','住院人数']
	    },
	    xAxis: [
	        {
	            type: 'category',
	            data: ['1月','2月','3月','4月','5月','6月','7月','8月'],
	            axisPointer: {
	                type: 'shadow'
	            }
	        }
	    ],
	    yAxis: [
	        {
	            type: 'value',
	            name: '人数',
	            min: 0,
	            max: 3000,
	            interval: 500,
	            axisLabel: {
	                formatter: '{value} 人'
	            }
	        }
	    ],
	    series: [
	        {
	            name:'门诊人数',
	            type:'bar',
	            data:[1020, 890, 782, 1200, 1500, 1300, 1972, 1198,]
	        },
	        {
	            name:'住院人数',
	            type:'bar',
	            data:[402, 340, 567, 409, 223, 189, 178, 182]
	        }
	    ]
	};
	c2.setOption(option);
}

$(function(){
	
	setChartHeight("#row1","#chart2");
	setChartHeight("#row1","#chart1");	
	setTbodyHeight("#row2","#tableTitle1","#tBody1");
	setTbodyHeight("#row2","#tableTitle2","#tBody2");
	var c1 = echarts.init(document.getElementById("chart1"));
	var c2 = echarts.init(document.getElementById("chart2"));
	drawChart1(c1);
	drawChart2(c2);
	
	
	
});

//function setHeight(){
//	var windowHeight = $(window).innerHeight();
//	$("#row1").height((windowHeight/2) + "px");
//	$("#row2").height((windowHeight/2) + "px");
//}


/*
	setChartHeight() 计算图表的高度
	参数row代表区块
	参数chart代表区块中的图表
 * */
function setChartHeight(row,chart){
	var rowHeight = $(row).height();
	var infoHeight = $("#mm").outerHeight(true);
	var chartHeight = rowHeight - infoHeight + "px";
	$(chart).height(chartHeight);
	$(".area").height((rowHeight / 2) + "px");
}

/*
	setTbodyHeight() 计算表格的高度
	参数row代表区块
	参数tableTitle代表表格名称，一个h4标签
	参数tbody代表表格内容区域
 * */
function setTbodyHeight(row,tableTitle,tbody){
	var rowHeight = $(row).height();
	var tableTitleHeight = $(tableTitle).outerHeight(true);
	var theadHeight = $(row).find(".t-head").outerHeight(true);
	var tbodyHeight = rowHeight - tableTitleHeight - theadHeight - 30 + "px";    //这里减了一个30像素
	$(tbody).css("height",tbodyHeight);
}
